home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Programming / LEDA / source / src / graph_alg / _spanning.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-16  |  1.1 KB  |  46 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  3.1c
  4. +
  5. +
  6. +  _spanning.c
  7. +
  8. +
  9. +  Copyright (c) 1994  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15.  
  16. /*******************************************************************************
  17. *                                                                              *
  18. *  SPANNING_TREE  (spanning tree)                                              *
  19. *                                                                              *
  20. *******************************************************************************/
  21.  
  22.  
  23. #include <LEDA/graph_alg.h>
  24. #include <LEDA/node_partition.h>
  25.  
  26.  
  27. list<edge> SPANNING_TREE(const graph& G)
  28. { node v,w;
  29.   edge e;
  30.   list<edge> EL;
  31.   node_partition P(G);
  32.  
  33.   forall_edges(e,G)
  34.      { v = source(e);
  35.        w = target(e);
  36.        if (! P.same_block(v,w))
  37.         { EL.append(e);
  38.           P.union_blocks(v,w);
  39.          }
  40.       }
  41.  
  42.   return EL;
  43. }
  44.  
  45.